package com.lujianfei.share;

import android.content.Context;

import com.lujianfei.share.shareBase.ShareBase;
import com.lujianfei.share.shareBase.SharePlatforms;
import com.lujianfei.share.shareBase.ShareType;
import com.lujianfei.share.shareMultiple.ShareMultiple;
import com.lujianfei.share.shareSingle.ShareSingle;

import java.util.Arrays;
import java.util.List;

public class ShareHelper {

    private Context context;
    private String title;
    private String content;
    private String dialogTitle;
    private String[] path;
    private List<SharePlatforms> platforms;
    public ShareHelper(Context context){
        this.context = context;
    }
    public ShareHelper share(String title, String content,String dialogTitle){
        this.title = title;
        this.content = content;
        this.dialogTitle = dialogTitle;
        return this;
    }
    public ShareHelper image(String[] path){
        this.path = path;
        return this;
    }
    public ShareHelper withPlatforms(SharePlatforms... platforms){
        this.platforms = Arrays.asList(platforms);
        return this;
    }
    public void show(){
        ShareBase shareBase;
        if (null!=path){
            if (path.length>1){
                shareBase = new ShareMultiple(context).share(title, content, dialogTitle).image(path).withPlatforms(platforms);
            }else {
                shareBase = new ShareSingle(context).share(title, content, dialogTitle).image(path).withPlatforms(platforms);
            }
        }else{
            shareBase = new ShareSingle(context).share(title,content,dialogTitle).withPlatforms(platforms);
        }
        shareBase.show();
    }
}
